package sketch.ounit.fuzz;

/**
 * TODO A potentially (significant) weakness of this class is the
 * AssembledSequence can not be reused. This is unlike the sequence
 * generated in randoop, which could be put back into the pool.
 * 
 * As a consequence, it may be less legal sequences being created.
 * 
 * To work around, set the use_arg_probability value to a higher value.
 * */
public interface AssembledSequence<T> {
	
	/**
	 * If user provides objects as arguments, this is the probability of using those
	 * user-provided objects.
	 * */
	public static float use_arg_probability = 0.7f;
	
	/**
	 * Assemble a sequence and execute it. It will return either a newly
	 * created object (null if fails), or a mutated objects.
	 * */
	public T assemble_and_execute_sequence();
	
	/**
	 * Convert the sequence to string format. For instance, if the original
	 * randoop sequence is:
	 * var0 = new A();
	 * var1 = var0.m("user provided object 1", var0)
	 * var2 = "receiver".n(var1)
	 * 
	 * using offset = 2, receiver = "obj", argnames = {"arg1"}, expressionNames = {"exp1"}, will
	 * result int he following sequence as output
	 * 
	 * var2 = new A();
	 * Type arg1 = expr1;
	 * var3 = var2.m(arg1);
	 * var4 = obj.n(var3);
	 * */
    public String toCodeString(int offset, String receiver, String[] argnames, String[] expressionNames);
	
    /**
     * Returns the size of assembled sequence. To keep simple, the size
     * here is the lines of code of each sequence.
     * */
	public int size();
	
	/**
	 * Returns the result variable produced by the sequence. It could be
	 * the name of a newly created value, or a mutated value.
	 * */
	public String getResultVar(int offset);
}